<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:fragment="comment">
<body>
<script type="text/javascript">
    (function () {
        window.TaleComment = {
            reply: function (coid,ownerid) {
                $('#comment-form input[name=coid]').val(coid);
                $('#comment-form input[name=ownerId]').val(ownerid);
                $("html,body").animate({scrollTop: $('div.comment-container').offset().top}, 500);
                $('#comment-form #textarea').focus();
            },
            subComment: function () {
                $.ajax({
                    type: 'post',
                    url: '/comment',
                    data: $('#comment-form').serialize(),
                    async: false,
                    dataType: 'json',
                    success: function (result) {
                        $('#comment-form input[name=coid]').val('');
                        if (result && result.success) {
                            window.location.reload();
                        } else {
                            if (result.msg) {
                                alert(result.msg);
                                window.location.reload();
                            }
                        }
                    }
                });
                return false;
            }
        };
    })();

    function getCommentCookie(name) {
        var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
        if (arr = document.cookie.match(reg))
            return unescape(decodeURI(arr[2]));
        else
            return null;
    }

    function addCommentInputValue() {
        document.getElementById('author').value = getCommentCookie('blog_remember_author');
        document.getElementById('mail').value = getCommentCookie('blog_remember_mail');
        document.getElementById('url').value = getCommentCookie('blog_remember_url');
    }

    addCommentInputValue();
</script>
</body>
</html>